import request, { req } from '@/utils/request';

export type LoginParamsType = {
  userName: string;
  password: string;
  mobile: string;
  captcha: string;
};

export interface loginParamsType {
  auth_type: string;
  password: string;
  phone: string;
  smsCode: string;
}
export interface loginType {
  phone: string;
  auth_type:'phone_free_token',
  token:string
}

export interface sendParamsType {
  phone: string;
  type: string;
}

export async function fakeAccountLogin(params: LoginParamsType | loginType) {
  return request('/api/login/account', {
    method: 'POST',
    data: params,
  });
}

export async function getFakeCaptcha(params: sendParamsType) {
  return request('/api/sms/send', {
    method: 'POST',
    data: params,
    requestType: 'form'
  })
}

export async function getPublicity(params: { pageNo: number; pageSize: number; type?: string }) {
  return request('/open/publicity/list', {
    method: 'GET',
    params,
  });
}

export async function downloadImgFile(params: { fileUrl: string }) {
  return req('/open/publicity/downloadFile', {
    method: 'POST',
    data: params,
    responseType: 'blob'
  })
}
